home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / D-G / DinkClass Shareware Package / DinkClass / DListStuff.h < prev    next >
Encoding:
Text File  |  1992-12-31  |  2.0 KB  |  98 lines  |  [TEXT/KAHL]

  1. /*
  2.     File:        DListStuff.h
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    Mark Gross
  7.  
  8.     Copyright:    © 1992 by Applied Technical Software, all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <3>    12/31/92    MTG        making the code conditionaly compiled so         that I am
  13.                                     always working with a current         version in either think c
  14.                                     or MPW C++
  15.          <2>    11/14/92    MTG        Bringing the C++ version up to date WRT the         ThinkC
  16.                                     version.
  17.  
  18.     To Do:
  19. */
  20.  
  21.  
  22. // This file contains the class declarations for 
  23. // Tlink Tlist and TIterator
  24. // The are all small classes and that is why
  25. // I've chosen to stuff them all into one
  26. // file.
  27.  
  28.  
  29. #ifndef __DLISTSTUFF__
  30. #define __DLISTSTUFF__
  31.  
  32. #include "DObject.h"
  33.  
  34.  
  35. class DLink
  36. {
  37. public:
  38.     
  39.     DLink*    fNext;
  40.     void*    fItem;
  41.     
  42.     
  43.     DLink*    Init(DLink *n, void *item);
  44.     DLink*    GetNext(void);
  45.     void*    GetItem(void);
  46.     void    SetNext(DLink* aLink);
  47.     void    SetItem(void* anItem);
  48. };// end of DLink class declaration
  49.  
  50.  
  51. class    DList    // of DObject instances!
  52. {
  53. public:
  54.     
  55.     DLink*    fLink;
  56.     
  57.     int        fNumItems;
  58.     
  59.     
  60.     DList*    Init(void);
  61.     void    AddItem(void* item);
  62.     Boolean    RemoveItem(void* item);
  63.     Boolean    ItemInList(void* item);
  64.     int        NumItems(void);
  65. };// end of DList class declaration
  66.  
  67. //
  68. // The iteration scheam could get lost in space if
  69. // the list interation is shortend as the itteration is going
  70. // resulting in problems.  To be safe avoid iterations where the list
  71. // is shortend durring the time the itterator is opperating on the list.
  72. //
  73.  
  74. class DIterator
  75. {
  76.     Boolean fInUse;
  77.         // this is set to be TRUE at Init time and FALSE when GetCurrentThenIncrement
  78.         // gets to the end of its list.  And if Init gets called while fInUse is true
  79.         // we drop into the debugger and let the developer about the BooBoo.
  80.  
  81. public:
  82.     DIterator(void);
  83.     ~DIterator(void);
  84.         // constructor sets fInUse to FALSE the destructor is just for style
  85.     
  86.     DLink*    fCurLink;
  87.     
  88.     
  89.     DIterator*    Init(DList* list);
  90.         // Sets up the iteration...
  91.         
  92.     void*    GetCurrentThenIncrement(void);
  93.         // dose what its name indicates....
  94. };// end of class declaration TIterator
  95.  
  96.  
  97.  
  98. #endif __DOBJECT__